<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style type="text/css">
#id1{
	color:#F00;
}
</style>
<script type="text/javascript" src="jq/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
$(function(){
	$("[type='submit']").click(function(){
		if($.trim($("[name='student.name']").val().length)==0){//判断用户名是否为空
			$("#id1").html("用户名不能为空");
			$("[name='student.name']").select()
			$("[name='student.name']").focus();
			return false;
		}
		var str=/^[\u4e00-\u9fa5]+$/;
		if(!str.test($("[name='student.name']").val())){//判断用户名的值是否为汉字
			$("#id1").html("请输入汉字");		
			$("[name='student.name']").select()
			$("[name='student.name']").focus();
			return false;
		}		
		if($.trim($("[name='student.pwd']").val().length)==0){//判断密码是否为空
			$("#id1").html("密码不能为空");
			$("[name='student.pwd']").select()
			$("[name='student.pwd']").focus();
			return false;
		}
		return true;	
	});	
});
</script>
</head>
<body>
登录
<br/>
<br/>
<form action="${pageContext.request.contextPath }/student/check" method="post">
<table>
<tr><td>用户名:</td><td><input type="text" name="student.name"/></td></tr>
<tr><td>密码:</td><td><input type="password" name="student.pwd" /></td></tr>
<tr><td colspan="2"><input type="submit" value="提交"/></td></tr>
</table>
</form>
<div id="id1"></div>
<br/>
<br/>
<a href="${pageContext.request.contextPath}/main.jsp">返回主页</a>
</body>
</html>